import java.util.Arrays;

public class TestDemo2 {
    public  static void change (int[]array){
        int i=0;
        int j= array.length-1;
        while(i<j){
            while(i<j&&array[i]%2!=0){
                i++;
            }
            while(i<j&&array[j]%2==0){
                j--;
            }
            int tmp=array[i];
            array[i]=array[j];
            array[j]=tmp;
        }
    }

    public static void main(String[] args) {
        int []array={1,2,3,4,5,6,7,8};
        change(array);
        System.out.println(Arrays.toString(array));
    }
    //数组元素扩大
    public static int[] transform(int []array){
        int []tmp=new int [array.length];
        for (int i = 0; i < array.length; i++) {
            tmp[i]=array[i]*2;
        }
        return tmp;
    }
    public static void transform1(int []array){
        for (int i = 0; i < array.length; i++) {
            array[i]=array[i]*2;
        }
    }
    public static void main1(String[] args) {
        int[] array={1,2,3};
        int [] ret=transform(array);
        System.out.println(Arrays.toString(ret));
        System.out.println(Arrays.toString(array));
    }


}